from typing import Optional

from model.uml_element import UmlElement
from model.uml_comment import UmlComment
from model.uml_xmi_info import UmlXmiInfo


class UmlOpaqueExpression(UmlElement):
    def __init__(self) -> None:
        super().__init__(UmlXmiInfo.type_opaque_expression)
        self.name: str = ""
        self.body: str = ""
        self.language: str = ""

    def to_json(self) -> dict[str, object]:
        json: dict = super().to_json()
        json["name"] = self.name
        json["body"] = self.body
        json["language"] = self.language

        if self.ownedComment is not None:
            json["ownedComment"] = self.ownedComment.to_json()

        return json
